package com.my.study.juc.basic.syn;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Carlos
 * @version 1.0
 * @Description TODO
 * @date 2021/4/11 19:42
 **/
public class UnsafeList {

    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        for (int i = 0; i < 10000; i++) {
            new Thread(() -> {
                synchronized (list) {
                    list.add(Thread.currentThread().getName());
                }

            }).start();
        }

        System.out.println(list.size());
    }

}
